import java.util.Scanner;

public class Demo6 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        StringBuilder builder = new StringBuilder();
        int times = 1;
        String tmp = outNumber(0,str.length()-1,str,builder,times);
        System.out.println(tmp);
    }

    private static String outNumber(int cur,int end,String str,StringBuilder builder,int times) {
        char tmp = str.charAt(cur);
        if (tmp != '(' && tmp != ')') {
            builder.append(tmp);
            if (cur + 1 <= end){
                char tmpNext = str.charAt(cur+1);
                if (tmpNext >= 'A' && tmpNext <= 'Z'){
                    builder.append(times);
                    outNumber(cur+1,end,str,builder,times);
                }else if (tmpNext >= '0' && tmpNext <= '9'){
                    int number = tmpNext - '0';
                    int result = times * number;
                    builder.append(result);
                    outNumber(cur+2,end,str,builder,times);
                }else if (tmpNext >= 'a' && tmpNext <= 'z' ){
                    outNumber(cur+1,end,str,builder,times);
                }else {
                    builder.append(times);
                    outNumber(cur+1,end,str,builder,times);
                }
            }else {
                if (tmp < '0' || tmp > '9'){
                    builder.append(1);
                }
            }
        }else {
            int right = findRight(str,cur+1,")");
            if (right == -1){
                return "输入不符合要求";
            }
            if (right + 1 <= end){
                char tmpNext = str.charAt(right+1);
                if (tmpNext >= '0' && tmpNext <= '9'){
                    int times1 = tmpNext - '0';
                    outNumber(cur+1,right -1,str,builder,times1);
                    if (right + 2 <= end){
                        outNumber(right+2,end,str,builder,times);
                    }
                }else {
                    outNumber(cur+1,right -1,str,builder,times);
                    if (right + 1 <= end){
                        outNumber(right+2,end,str,builder,times);
                    }
                }
            }
        }
        return builder.toString();
    }

    private static int findRight(String str,int right, String s) {
        for (int i = right; i < str.length(); i++) {
            if (str.charAt(i) == ')') return i;
        }
        return -1;
    }
}
